package com.lx.yygh.cmn.api;

import com.lx.yygh.cmn.service.DictService;
import com.lx.yygh.common.result.Result;
import com.lx.yygh.model.cmn.Dict;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @author c先生
 * @date 2022年10月19日 下午 5:20:14
 * @describe
 */
@Api(tags = "数据字典模块(对外访问)")
@RestController
@RequestMapping("/api/cmn/dict")
public class DictApiController {
    @Resource
    DictService dictService;

    @ApiOperation(value = "查询医院等级列表")
    @GetMapping("/findByDictCode/{dictcode}")
    public Result findByDictCode(@PathVariable("dictcode")String dictcode){
        //根据dictcode查询所有的字典数据，由于查省份跟查医院等级相同，所以这里直接复用了
        List<Dict> list = dictService.getProvinceList(dictcode);
        return Result.ok(list);
    }

    @GetMapping("findByParentId/{parentId}")
    public Result findByParentId(@PathVariable("parentId")Long parentId){
        List<Dict> list = dictService.findDictEeVo(parentId);
        return Result.ok(list);
    }
}
